import {Context, Response} from 'koa'
import { User } from '../models/index'
import {createConnection} from "typeorm";
const {database} = require('../config')

async function srv(ctx: Context, next: Function){
    try{
        const conn = await createConnection(database)
        const user = new User()
        user.username = 'aaa'
        user.password = 'aaa'
        const result = await conn.manager.save(user)
        console.log('保存成功')
        ctx.body = result
        await conn.close()
    }catch(e) {
        console.log('error', e)
    }
}

module.exports = {
    srv
}